﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Media.Media3D;
using System.Windows.Shapes;
using System.Xml.Linq;
using CommunityToolkit.Mvvm.ComponentModel;

namespace WpfApp3d
{
    /// <summary>
    /// Window1.xaml 的交互逻辑
    /// </summary>
    public partial class Window1 : Window
    {
        private ABC vm = new ABC() { T=new TestA() {Age="30" } };
        public Window1()
        {
            
            InitializeComponent();
            this.DataContext = vm;

            List<Category> categories = new List<Category>
        {
            new Category { CategoryID = 1, CategoryName = "Beverages" },
            new Category { CategoryID = 2, CategoryName = "Condiments" }
        };

            List<Product> products = new List<Product>
        {
            new Product { ProductID = 1, ProductName = "Tea", CategoryID = 1 },
            new Product { ProductID = 2, ProductName = "Mustard", CategoryID = 2 },
            new Product { ProductID = 3, ProductName = "Coffee", CategoryID = 1 },
            new Product { ProductID = 4, ProductName = "Soy Sauce", CategoryID = 2 }
        };


          var query=  categories.GroupJoin(products, pro => pro.CategoryID, cate => cate.CategoryID, (a, b) => new {ab=a,ac=b }).ToList();

            foreach (var item in query)
            {
                Console.WriteLine(item.ab.CategoryName);
                foreach (var a in item.ac)
                {
                    Console.WriteLine(a.ProductName);
                }

                Console.WriteLine("--------------------");
            }

        }

        private void Button_Click(object sender, RoutedEventArgs e)
        {
            var transform = new TranslateTransform3D(new Vector3D(3, 3, 0));
            //this.test.Transform = transform;


            

            var t = new RotateTransform3D();
            t.Rotation = new AxisAngleRotation3D() { Angle = 40, Axis = new Vector3D(0, 0, 1) };

            var te = Matrix3D.Multiply(transform.Value, t.Value);

            this.test.Transform = new MatrixTransform3D(te);
        }

        private void Button_Click_1(object sender, RoutedEventArgs e)
        {
            vm.Name = "张山";
            vm.T.Age = "60";
        }
    }
    public partial class ABC: ObservableObject
    {
        private string name;

        public string Name
        {
            get
            {
                return name;
            }
            set
            {
                name = value;
               OnPropertyChanged();
            }
        }

        public TestA T { get; set; }
    }

    public class TestA: ObservableObject
    {
        private string name;

        public string Age
        {
            get
            {
                return name;
            }
            set
            {
                name = value;
                OnPropertyChanged();
            }
        }
    }


    class Category
    {
        public int CategoryID { get; set; }
        public string CategoryName { get; set; }
    }

    class Product
    {
        public int ProductID { get; set; }
        public string ProductName { get; set; }
        public int CategoryID { get; set; }
    }
}
